Ext.ns('net.autodata.compare.plugins');
(function() {
    
    /**
    * @class CompareVehiclesNavigation
    * @extends Ext.util.Observable
    * @namespace net.autodata.compare.plugins 
    */
    var Plugin = Ext.extend(Ext.util.Observable, {

        comparePanel: undefined,

        init: function(comparePanel) {
            this.comparePanel = comparePanel;

            this.comparePanel.on({
                'changebasevehicle': this.onChangeBaseVehicle,
                'destroy': this.onDestroy,
                scope: this
            });
        },

        /**
        * @method onChangeBaseVehicle
        * @private
        */
        onChangeBaseVehicle: function() {
        	var session = net.autodata.Session.getInstance();
			var url = session.getPageUrls()['vehicle select'];
			if (url) {
				window.location.href = url;
			}
        },

        /**
        * @method onDestroy
        * @private
        */
        onDestroy: function() {
            this.comparePanel.un({
                'changebasevehicle': this.onChangeBaseVehicle,
                'destroy': this.onDestroy,
                scope: this
            });
        }
    });

    net.autodata.compare.plugins.CompareVehiclesNavigation = Plugin;
})();